/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufc.quixada.adrs.comandos.visit;

import br.ufc.quixada.adrs.interfaces.Comando;
import br.ufc.quixada.adrs.model.Adrs;
import br.ufc.quixada.adrs.service.AdrsService;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 *
 * @author Escritorio projetos
 */
public class CmdVisitListarAdrsLetraInicial implements Comando {

    public String executa(HttpServletRequest request, HttpServletResponse response) {
        String letra = request.getParameter("letra");
        if (letra.length() != 1) {
            request.getSession().setAttribute("erro", "Consulta não permitida!");
        } else {
            List<Adrs> lista = null;
            lista =  new AdrsService().getPaginaAdrsByLetraInicial(letra, 0L, 10l);
            request.getSession().setAttribute("listaAdrs", lista);
            request.getSession().setAttribute("pagePorLetra", letra);
        }
        return "/visit/visit_gerenciar_adrs.jsp";
    }
}
